#include<bits/stdc++.h>
#define y1 Y1
#define fi first
#define endl "\n"
#define se second
#define PI acos(-1)
#define int long long
#define pb(x) push_back(x)
#define PII pair<int, int>
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define _for(i, a, b) for(int i = a; i <= b; ++i)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;

const int N = 110;
char a[N][N];
bool st[N][N];
int w, h;
int ret;
int dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

bool check(int x, int y) {
	return x >= 1 && x <= h && y >= 1 && y <= w && a[x][y] == '.' && !st[x][y];
}

void dfs(int x, int y) {
	
	for(int i = 0; i < 4; ++ i ) {
		int dx = x + dir[i][0];
		int dy = y + dir[i][1];
		if(check(dx, dy)) {
			st[dx][dy] = true;
			ret++;
			dfs(dx, dy);
		}
	}
}

signed main() {
	IOS;
	while(true) {
		ret = 0;
		int x, y;
		cin >> w >> h;
		if(w == 0 && h == 0)return 0;
		memset(st, false, sizeof st);
		
		_for(i, 1, h) {
			_for(j, 1, w) {
				cin >> a[i][j];
				if(a[i][j] == '@') {
					x = i, y = j;
				}
			}
		}
		st[x][y] = true;
		dfs(x, y);
		cout << ret + 1<< endl;
	}

	return 0;
}

